<template>
  <!-- 消防信息 -->
  <div>
    <public-modal
      width="900px"
      :footer="false"
      title="技防信息"
      modalStyle="detailModal"
      :publicVisible="publicVisible"
      cancelContext="拒绝"
      confirmContext="通过"
      @cancel="cancel"
    >
      <div slot="content">
        <!-- 安全通道 -->
        <div class="base-info-wrap" v-if="monitorInfo.onMonitor !== null">
          <div class="common-title">
            <div class="icon"></div>
            <div class="content">监控摄像头</div>
          </div>

          <div class="content-wrapper base-content-wrapper">
            <div class="flex">
              <div class="info-wrap f1">
                <div class="label common-lable">有无</div>
                <div class="value common-value">
                  {{ monitorInfo.onMonitor == 1 ? '有' : '无' || '暂无' }}
                </div>
              </div>
              <div class="info-wrap f1" v-if="monitorInfo.onMonitor == 1">
                <div class="label common-lable">数量</div>
                <div class="value common-value">{{ monitorInfo.monitorCount }}</div>
              </div>
              <div class="info-wrap f1" v-if="monitorInfo.onMonitor == 1">
                <div class="label common-lable">照片</div>
                <div class="value common-value click-color cursor" @click="werImg('monitorImgList')">查看</div>
                <ul id="monitorImgList" style="display: none">
                  <li v-for="(item, index) in monitorImgList" :key="index">
                    <img :src="imgPrefix + item" :data-original="imgPrefix + item" />
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </div>

        <div class="base-info-wrap" v-if="reportInfo.onReport !== null">
          <div class="common-title">
            <div class="icon"></div>
            <div class="content">自动报警设备</div>
          </div>

          <div class="content-wrapper base-content-wrapper">
            <div class="flex">
              <div class="info-wrap f1">
                <div class="label common-lable">有无</div>
                <div class="value common-value">
                  {{ reportInfo.onReport == 1 ? '有' : '无' || '暂无' }}
                </div>
              </div>
              <div class="info-wrap f1" v-if="reportInfo.onReport == 1">
                <div class="label common-lable">数量</div>
                <div class="value common-value">{{ reportInfo.reportCount }}</div>
              </div>
              <div class="info-wrap f1" v-if="reportInfo.onReport == 1">
                <div class="label common-lable">照片</div>
                <div class="value common-value click-color cursor" @click="werImg('reportImgList')">查看</div>
                <ul id="reportImgList" style="display: none">
                  <li v-for="(item, index) in reportImgList" :key="index">
                    <img :src="imgPrefix + item" :data-original="imgPrefix + item" />
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div slot="footer"></div>
    </public-modal>
  </div>
</template>
<script>
import Viewer from 'viewerjs'
import 'viewerjs/dist/viewer.css'
import publicModal from '@/components/publicModal'
import { comMethods } from '@/mixins/comMethods'
import { getAction } from '@/api/manage'
export default {
  name: 'detailModal',
  components: { publicModal },
  mixins: [comMethods],
  data() {
    return {
      imgPrefix: '',
      publicVisible: false,

      secureChannelInfo: {}, //	安全通道信息
      floodlightInfo: {}, //	应急照明灯信息
      fireHydrantInfo: {}, //	消防栓信息
      emergencyPlanInfo: {}, //	应急预案信息
      fireToolInfo: {}, //	消防器材信息
      securityDoorInfo: {}, //	防盗门信息
      securityWindowInfo: {}, //	防盗窗信息
      protectiveFenceInfo: {}, //	防护栏信息
      safeInfo: {}, //	保险柜信息
      securitySystemInfo: {}, //	安全制度信息
      monitorInfo: {}, //	监控信息
      monitorImgList: [],
      reportInfo: {}, //	自动报警设备信息
      reportImgList: [],
      airDefenseInfo: {}, //	人防信息

      bizId: '',
    }
  },

  methods: {
    show(records) {
      this.companyId = records.companyId
      this.getPublicSecurityDetail()
      this.publicVisible = true
    },

    async getPublicSecurityDetail() {
      let {
        result: {
          secureChannelInfo,
          floodlightInfo,
          fireHydrantInfo,
          emergencyPlanInfo,
          fireToolInfo,
          securityDoorInfo,
          securityWindowInfo,
          protectiveFenceInfo,
          safeInfo,
          securitySystemInfo,
          monitorInfo,
          reportInfo,
          airDefenseInfo,
        },
      } = await getAction('/industry/public_security/detail', { companyId: this.companyId })

      this.bizId = secureChannelInfo.id
      this.secureChannelInfo = secureChannelInfo
      this.floodlightInfo = floodlightInfo
      this.fireHydrantInfo = fireHydrantInfo
      this.emergencyPlanInfo = emergencyPlanInfo
      this.fireToolInfo = fireToolInfo
      this.securityDoorInfo = securityDoorInfo
      this.securityWindowInfo = securityWindowInfo
      this.protectiveFenceInfo = protectiveFenceInfo
      this.safeInfo = safeInfo
      this.securitySystemInfo = securitySystemInfo
      this.monitorInfo = monitorInfo
      this.reportInfo = reportInfo
      this.airDefenseInfo = airDefenseInfo

      this.getCompanyPhoto()
    },

    async getCompanyPhoto() {
      let { result: monitorImgList } = await getAction('/sys/images_path/list', { bizId: this.bizId, bizType: 15 })
      monitorImgList.forEach((item) => {
        this.monitorImgList.push(item.path)
      })
      let { result: reportImgList } = await getAction('/sys/images_path/list', { bizId: this.bizId, bizType: 16 })
      reportImgList.forEach((item) => {
        this.reportImgList.push(item.path)
      })
      // console.log(this.imgPrefix, this.monitorImgList, this.reportImgList, 'resultresultresult')
    },

    cancel(target) {
      this.monitorImgList = []
      this.reportImgList = []
      this.publicVisible = false
    },

    werImg(id) {
      const ViewerDom = document.getElementById(id)
      const viewer = new Viewer(ViewerDom, {
        toolbar: true,
        button: true,
        navbar: true,
        title: false,
        url: 'data-original',
        hide: function () {
          viewer.destroy()
        },
      })
      viewer.show()
    },
  },
}
</script>
<style scoped lang="less">
/deep/ .modalCotent {
  padding: 20px 40px;
  border-radius: 0 0 4px 4px;
}

img {
  display: none;
}

.base-content-wrapper {
  .common-lable {
    width: 120px !important;
  }
  .common-value {
    width: auto !important;
  }
}
</style>
